#include <iostream>
using namespace std;
#include "mytime.h"

Time::Time() { _hour = _minutes = 0; }
Time::Time(int h, int m) {
  _hour = h;
  _minutes = m;
}
void Time::AddMin(int m) {
  _minutes += m;
  _hour += _minutes / 60;
  _minutes %= 60;
}
void Time::AddHr(int h) { _hour += h; }
void Time::Reset(int h, int m) {
  _hour = h;
  _minutes = m;
}
Time Time::Sum(const Time &t) const {
  Time sum;
  sum._minutes = _minutes + t._minutes;
  sum._hour = _hour + t._hour + sum._minutes / 60;
  sum._minutes %= 60;
  return sum;
}
void Time::Show() const { cout << _hour << ":" << _minutes << endl; }
Time Time::operator+(const Time &t) const {
  Time sum;
  sum._minutes = _minutes + t._minutes;
  sum._hour = _hour + t._hour + sum._minutes / 60;
  sum._minutes %= 60;
  return sum;
}
Time Time::operator-(const Time &t) const {
  Time diff;
  int tot1, tot2;
  tot1 = t._minutes + t._hour * 60;
  tot2 = _minutes + _hour * 60;
  diff._minutes = (tot2 - tot1) % 60;
  diff._hour = (tot2 - tot1) / 60;
  return diff;
}
Time Time::operator*(double n) const {
  Time result;
  long totalmin = _hour * n * 60 + _minutes * n;
  result._hour = totalmin / 60;
  result._minutes = totalmin % 60;
  return result;
}
std::ostream &operator<<(std::ostream &os, const Time &t) {
  os << t._hour << " hours," << t._minutes << " minutes";
  return os;
}
